<template>
  <a-modal
    :confirmLoading="confirmLoading"
    :maskClosable="false"
    :title="title"
    :visible="visible"
    :width="1200"
    cancelText="关闭"
    @cancel="handleCancel"
    @ok="handleOk">
    <template slot="footer">
      <a-button @click="handleCancel">取消</a-button>
      <a-button v-if="!disableSubmit" :disabled="isDisable" :loading="confirmLoading" type="primary" @click="handleOk">
        确认
      </a-button>
    </template>
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-row :gutter="24">
          <a-col :md="12" :sm="24">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="门店名称"
            >
              <a-input v-decorator="['terminalName', validatorRules.terminalName]" :disabled="disableSubmit"
                       placeholder="请输入门店名称"/>
            </a-form-item>
          </a-col>
          <!--          行政区域-->
          <a-col :md="12" :sm="24">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="行政区域"
            >
              <j-area-linkage v-model="areaLinkage" :area.sync="form.area" :city.sync="form.city"
                              :disabled="disableSubmit"
                              :province.sync="form.province" type="cascader" @change="handlePca"/>
            </a-form-item>
          </a-col>
          <!--          详细地址-->
          <a-col :md="12" :sm="24">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="详细地址"
            >
              <a-input v-decorator="['address', validatorRules.address]" :disabled="disableSubmit"
                       placeholder="请输入地址"/>
            </a-form-item>
          </a-col>
          <!--          营业执照-->
          <a-col :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="营业执照代码">
              <a-input v-decorator="['businessLicense', validatorRules.businessLicense]" :disabled="disableSubmit" maxLength='18'
                       placeholder="请输入"/>
            </a-form-item>
          </a-col>
          <a-col :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="烟草许可证号">
              <a-input v-decorator="[ 'smokeLicenceNum',validatorRules.smokeLicenceNum]" :disabled="disableSubmit" maxLength='12'
                       placeholder="请输入"/>
            </a-form-item>
          </a-col>
          <a-col :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="烟草许可证有效期">
              <a-range-picker v-decorator="['smokeLicenceDate',validatorRules.smokeLicenceDate]"
                              :disabled="disableSubmit" format="YYYY-MM-DD"
                              style="width: 100%;" valueFormat="YYYY-MM-DD"></a-range-picker>
            </a-form-item>
          </a-col>
          <a-col :md="12" :sm="24">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="门店类型"
            >
              <cn-dict-select-tag v-decorator="['terminalType',validatorRules.terminalType]" :disabled="disableSubmit"
                                  :options="{value:'dictDataCode',label:'dictDataDesc'}" :triggerChange="true"
                                  dictCode="terminal_type" placeholder="请选择门店类型"/>
            </a-form-item>
          </a-col>
          <!--门店等级-->
          <a-col :md="12" :sm="24">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="门店等级"
            >
              <cn-dict-select-tag v-decorator="['terminalLevel',validatorRules.terminalLevel]" :disabled="disableSubmit"
                                  :options="{value:'dictDataCode',label:'dictDataDesc'}" :triggerChange="true"
                                  dictCode="terminal_level" placeholder="请选择门店级别"/>
            </a-form-item>
          </a-col>
          <a-col :md="12" :sm="24">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="所属组织"
            >
              <j-tree-select
                ref="selectRef"
                v-decorator="['orgCode', validatorRules.orgCode]"
                :disabled="disableSubmit"
                data-type="org"
                placeholder="选择组织"
                @change="handleDepartCode"
              />
            </a-form-item>
          </a-col>

          <a-col :md="12" :sm="24">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="是否总店"
            >
              <cn-dict-select-tag v-decorator="['headOffice']" :disabled="disableSubmit"
                                  :options="{value:'dictDataCode',label:'dictDataDesc'}" :triggerChange="true"
                                  dictCode="head_office_status" placeholder="请选择是否总店"/>
            </a-form-item>
          </a-col>
          <a-col :md="12" :sm="24">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="面积"
            >
              <a-input v-decorator="['acreage']" :disabled="disableSubmit" placeholder="请输入"/>
            </a-form-item>
          </a-col>
          <a-col :md="12" :sm="24">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="营业时间">
              <a-time-picker v-decorator="[ 'businessStartDate']" :disabled="disableSubmit" format="HH:mm"
                             valueFormat="HH:mm"/>
              <span> ~ </span>
              <a-time-picker v-decorator="[ 'businessEndDate']" :disabled="disableSubmit" format="HH:mm"
                             valueFormat="HH:mm"/>
            </a-form-item>
          </a-col>
          <a-col :md="24" :sm="24">
            <a-form-item
              :labelCol="{
                xs: { span: 12 },
                sm: { span: 3 }
              }"
              :wrapperCol="{
                xs: { span: 24 },
                sm: { span: 8 }
              }"
              label="店员数量"
            >
              <a-input v-decorator="['clerkNum']" :disabled="disableSubmit" placeholder="请输入" style="width: 378px"/>
            </a-form-item>
          </a-col>
          <a-col :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="烟草许可证">
              <j-image-upload v-decorator="['retailLicenceImg']"
                              :disabled="disableSubmit" class="avatar-uploader"
                              text="上传"></j-image-upload>
            </a-form-item>
          </a-col>
          <a-col :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="门头照">
              <j-image-upload :disabled="disableSubmit" class="avatar-uploader" text="上传"
                              v-decorator="[ 'avatar', {}]"></j-image-upload>
            </a-form-item>
          </a-col>
          <a-col :md="12" :sm="24">
            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="陈列照">
              <j-upload v-decorator="['disPlayImgList']" :disabled="disableSubmit"
                        :number="3" :oldList="disPlayImgList"
                        :returnUrl="false"
                        accept=".png,.jpg,.jpeg" class="avatar-uploader"
                        fileType="image"
                        text="3张内"
                        @change="pdLogoChange"></j-upload>
            </a-form-item>
            <!--            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="陈列照">-->
            <!--              <j-image-upload v-decorator="[ 'disPlayImgList',validatorRules.disPlayImgList]" :disabled="disableSubmit" class="avatar-uploader"-->
            <!--                              text="上传"></j-image-upload>-->
            <!--            </a-form-item>-->
          </a-col>
          <!--          联系人-->
          <a-divider orientation="left" style="font-weight: 600;margin-top: 100px;">联系人电话</a-divider>
          <div v-for="(item,index) in forms" key="index">
            <a-form-model :label-col="labelCol" :rules="rules" :wrapper-col="wrapperCol">
              <a-col :md="8" :sm="24">
                <a-form-model-item
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  label="联系人"
                  prop="contacts"
                >
                  <a-input v-model="item.contacts" :disabled="disableSubmit" placeholder="请输入联系人"/>
                </a-form-model-item>
              </a-col>
              <!--          联系电话-->
              <a-col :md="8" :sm="24">
                <a-form-model-item
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  label="联系电话"
                  prop="telephone"
                >
                  <a-input v-model="item.telephone"
                           :disabled="disableSubmit" placeholder="请输入联系电话"
                            oninput="value=value.replace(/[^\d]/g,'')"/>
                </a-form-model-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-model-item
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  label="是否主号"
                  prop="isMainStr"
                >
                  <a-select
                    v-model="item.isMainStr"
                    :disabled="disableSubmit"
                    placeholder="请选择"
                    @change="sexChangeEvent($event,index)"
                  >
                    <a-select-option value="是">
                      是
                    </a-select-option>
                    <a-select-option value="否">
                      否
                    </a-select-option>
                  </a-select>
                </a-form-model-item>
              </a-col>
            </a-form-model>
            <a-button v-if="!disableSubmit" style="position: relative;right: -1150px;top: -38px;" type="primary"
                      @click="clickToadd($event,index)">{{ index == 0 ? '+' : '-' }}
            </a-button>
          </div>
        </a-row>
      </a-form>
    </a-spin>

    <!--      下方表单-->


    <div style="display: flex;padding-left: 5.5%;padding-top:10px">
      <h4 style="margin-right: 5px;font-weight: 700;font-size: 18px">其他信息</h4>
    </div>
    <a-form-item
    >
      <a-textarea v-model="remarks" :disabled="disableSubmit" allow-clear placeholder="请输入备注"
                  style="width:90%;margin-left:5%;min-height: 80px"/>
    </a-form-item>
    <CodeConfigModal
      ref="CodeConfigModal"
      :showCode="showCode"
      modal-width="90%"
      @ok="handelSaveOk">
    </CodeConfigModal>
    <proChose ref="prochoose" v-bind="modalProps" @okbro="okbropro"></proChose>

  </a-modal>
</template>

<script>
import ProduceList from '../modulesForndz/ProduceList'
import newCustperson from '../modulesForndz/newCustperson'
import CodeConfigModal from '../modulesForndz/CodeConfigMdal'
import { getAction, httpAction, postAction } from '@/api/manage'
import { pick } from 'lodash'
import moment from 'moment'
import JTreeSelect from '@/components/cn-form/JTreeSelect'
import JAreaLinkage from '@comp/cn-form/CnAreaLinkage'
import { isMobile, isPermit } from '@/utils/validate'
import UploadImage from '@/components/upload-image/UploadImage'
import JImageUpload from '@/components/cn-form/JImageUpload'
import Area from '@/components/utils/Area'
import proChose from '@comp/cn-components/ProChose'
import JUpload from '@/components/cn-form/JUpload'

export default {
  name: 'terminal-modal',
  components: {
    JTreeSelect,
    JAreaLinkage,
    UploadImage,
    JImageUpload,
    CodeConfigModal,
    newCustperson,
    ProduceList,
    proChose,
    JUpload
  },
  data() {
    return {
      disPlayImgList: [], //陈列图片
      objs: [],
      title: '',
      isDisable: false, //提交按钮状态
      sendPro: false,
      ProductAdress: [],
      remarks: '',
      dataSurces2: [],
      formChoice: [],
      showCode: false,
      remembertext: '',
      dataSource: [],
      maninumd: [],
      arrcont: [],
      cycle: 1,
      forms: [{
        isMainStr: '是',
        contacts: '',
        telephone: '',
        isMain: ''
      }],
      dataSurces: [],
      // dataSurces3: [],
      manobjList: [0],
      selectedRowKeys6: [],
      selectionRows6: [],
      areaData: '',
      areaLinkage: '',
      visible: false,
      visible1: false,
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      confirmLoading: false,
      form: this.$form.createForm(this),
      //formModel表单验证规则
      rules: {
        contacts: [
          { required: true, message: '', trigger: 'submit' }
        ],
        telephone: [
          { required: true, message: '', trigger: 'submit' }
        ],
        isMainStr: [
          { required: true, message: '', trigger: 'submit' }
        ]
      },
      validatorRules: {
        //烟草许可证号
        smokeLicenceNum: {
          rules: [
            { required: true, message: '',trigger: 'submit' }
          ]
        },
        //行政区域
        province: {
          rules: [
            { required: true, message: '',trigger: 'submit' }
          ]
        },
        //烟草许可证有效日期
        smokeLicenceDate: {
          rules: [
            { required: true, message: '' }
          ]
        },
        //零售许可证
        retailLicenceImg: {
          rules: [
            { required: true, message: '请上传图片', trigger: 'submit' }
          ]
        },
        //陈列照
        disPlayImgList: {
          rules: [
            { required: true, message: [], trigger: 'submit' }
          ]
        },
        businessLicense: {
          rules: [
            { required: true, message: '', trigger: 'submit' }
          ]
        },
        terminalName: {
          rules: [
            { required: true, message: '请输入门店名称' }
          ]
        },
        warehouseName: {
          rules: [
            { required: true, message: '请选择所属仓库' }
          ]
        },
        address: {
          rules: [
            { required: true, message: '请输入详细地址' }
          ]
        },
        dictDataCode: {
          rules: [
            { required: true, message: '请选择渠道类型' }
          ]
        },
        terminalType: {
          rules: [
            { required: true, message: '请选择门店类型' }
          ]
        },
        terminalLevel: {
          rules: [
            { required: true, message: '请选择门店等级' }
          ]
        },
        store: {
          rules: [
            { required: true, message: '请选择是否总仓' }
          ]
        },
        contacts: {
          rules: [
            { required: true, message: '' }
          ]
        },
        parentRealName: {
          rules: [
            { required: true, message: '' }
          ]
        },
        orgCode: {
          rules: [
            { required: true, message: '请选择所属组织' }
          ]
        }
      },
      addOrUpdateUrl: window._CONFIG['domianURL'] + '/cnTerminalController/saveOrUpdateTerminal',
      list: window._CONFIG['domianURL'] + '/cnTerminalController/custFindTerminalList',

      getCustmen: window._CONFIG['domianURL'] + '/terminal/cnRTermPtPos/findCustCodeForUserPos',

      warehouse: window._CONFIG['domianURL'] + '/warehouse/cnWarehouse/findPageList',

      editTerminal: window._CONFIG['domianURL'] + '/terminal/cnRTermPtPos/findProductsByCustCode'
    }
  },
  created() {
    this.initAreaData()
    // console.log(this.areaData);
  },
  methods: {
    //陈列图片上传
    pdLogoChange(e) {
      this.disPlayImgList = []
      e.forEach(item => {
        this.disPlayImgList.push({
          url: item.url,
          name: item.name,
          uid: item.uid,
          status: 'done'
        })
      })
    },
    //添加请求参数，组织改变时，改变请求参数
    handleDepartCode(value, name) {
      console.log(name)
      this.model.departCode = ''
      this.model.departName = name
    },
    //关联客户返回数据
    okbropro(val, status, status2) {
      let objs = JSON.parse(JSON.stringify(val[0]))
      this.objs = objs
      this.form.setFieldsValue({
        custName: objs.custName,
        custCode: objs.custCode
      })
    },

    productSearch(status) {
      this.$refs.prochoose.rowKey = 'id'
      let formconfig = [
        {
          key: 'custCode',
          label: '客户编码'
        },
        {
          key: 'custName',
          label: '客户名称'
        }
      ]
      let tableconfig = {
        columns: [
          {
            title: '客户编码',
            align: 'left',
            dataIndex: 'custCode',
            width: 120,
            ellipsis: true
          },
          {
            title: '客户名称',
            align: 'left',
            dataIndex: 'custName',
            width: 120,
            ellipsis: true
          }
        ],
        list: window._CONFIG['domianURL'] + '/customerController/getPageListElse',
        multiple: false,
        columW: 10
      }

      this.name = '用户'
      let dataSource = []
      if (this.form.getFieldValue('superiorUser')) {
        dataSource = [{
          userName: this.form.getFieldValue('superiorUser'),
          realName: this.form.getFieldValue('realsname')
        }]
      }
      console.log(dataSource)
      this.$refs.prochoose.edit(formconfig, tableconfig, 'superiorUser', 'realsname', dataSource)
    },
    handlePca(code) {
      console.log(code)
      this.model.provinceCode = code[0]
      this.model.cityCode = code[1]
      this.model.areaCode = code[2]
      this.model.province = this.areaData.getText(code).split('/')[0]
      this.model.city = this.areaData.getText(code).split('/')[1]
      this.model.area = this.areaData.getText(code).split('/')[2]
    },
    randomHexColor() { //随机生成十六进制颜色
      var hex = Math.floor(Math.random() * 16777216).toString(16) //生成ffffff以内16进制数
      while (hex.length < 6) { //while循环判断hex位数，少于6位前面加0凑够6位
        hex = '0' + hex
      }
      return '#' + hex //返回‘#'开头16进制颜色
    },
    add() {
      // this.edit({})
      this.form.resetFields()
      this.visible = true
    },
    edit(record) {
      console.log(record)
      if (record.extendVos) {
        this.forms = record.extendVos
      } else {
        //新增时，防止联系人数据回显
        this.forms = [{
          isMainStr: '请选择',
          contacts: '',
          telephone: '',
          isMain: ''
        }]
      }
      this.ProductAdress = []
      this.form.resetFields()
      this.model = Object.assign({}, record)
      this.model.smokeLicenceDate = [this.model.smokeLicenceStartDate, this.model.smokeLicenceEndDate]
      let disPlayImgList = []
      this.model.disPlayImgList.forEach(item => {
        disPlayImgList.push({
          url: item.displayImg
        })
      })
      this.disPlayImgList = disPlayImgList
      this.model.disPlayImgList = disPlayImgList
      console.log(this.model.disPlayImgList)
      this.dataSurces2 = record.tptposVos || []
      let pca = this.model.province + '/' + this.model.city + '/' + this.model.area
      this.areaLinkage = this.areaData.getAreaCodeByText(pca) || ''
      this.visible = true
      this.$nextTick(() => {
        setTimeout(() => {
          this.form.setFieldsValue({
            orgName: '请选择'
          })
          this.form.setFieldsValue(pick(this.model, Object.keys(this.model)))
          //时间格式化
          this.form.setFieldsValue({ punchTime: this.model.punchTime ? moment(this.model.punchTime, 'YYYY-MM-DD HH:mm:ss') : null })
          this.form.setFieldsValue({ birthday: this.model.birthday ? moment(this.model.birthday) : null })
        }, 200)
      })
      if (typeof record.createName == 'undefined') {
        this.sendPro = false
      } else {
        let Address = []
        if (this.model.addresses) {
          this.model.addresses.forEach(item => {
            Address.push(item)
          })
        }
        this.ProductAdress = Address
        this.sendPro = true
      }
    },
    close() {
      this.$emit('close')
      this.visible = false
      this.forms =  [{
        isMainStr: '请选择',
        contacts: '',
        telephone: '',
        isMain: ''
      }]
      this.areaLinkage= ''
      this.remarks = ''
      this.disPlayImgList = []

    },
    onSelectChange6(selectedRowKeys, selectionRows) {
      this.selectedRowKeys6 = selectedRowKeys
      this.selectionRows6 = selectionRows
    },

    handleOk1() {
      this.visible1 = false
      // this.model.warehouseName =
      this.form.setFieldsValue({
        warehouseName: this.selectionRows6[0].warehouseName
      })
      this.model.warehouseCode = this.selectionRows6[0].warehouseCode

    },
    handleOk() {
      this.isDisable = true
      console.log(this.forms)
      const that = this
      let reg = /^1[3-9]\d{9}$/
      for (let idx = 0; idx < this.forms.length; idx++) {
        if (this.forms[idx].isMainStr == '请选择' || this.forms[idx].contacts == undefined || this.forms[idx].telephone == undefined) {
          this.$message.info('请补充完联系人信息')
          this.isDisable = false
          return
        } else if (!reg.test(this.forms[idx].telephone)) {
          this.$message.info('请输入正确的手机号')
          this.isDisable = false
          return
        } else if (this.forms[idx].isMainStr == '是') {
          this.forms[idx].isMain = 1
        } else {
          this.forms[idx].isMain = 0
        }
      }
      if (that.areaLinkage == '') {
        that.$message.info('请选择门店所在省市区')
        this.isDisable = false
        return
      }      // 触发表单验证
      this.form.validateFields((err, values) => {
        let formData = Object.assign(this.model, values)
        if (formData.businessLicense.length !== 18) {
          this.$message.info('请输入18位营业执照代码')
          this.isDisable = false
          return
        }
        if(formData.smokeLicenceNum.length !== 12){
          this.$message.info('请输入12位烟草许可证号')
          this.isDisable = false
          return
        }
        console.log(values)
        if (!err) {
          that.confirmLoading = true
          let method = ''
          if (!this.model.id) {
            method = 'post'
          } else {
            method = 'post'
          }
          let formData = Object.assign(this.model, values)
          // if (formData.headOfficeStr == '是') {
          //   formData.headOffice = 1
          // } else if (formData.headOfficeStr == '否') {
          //   formData.headOffice = 0
          // }
          if (formData.supplyMethodStr == '间供') {
            formData.supplyMethod = 1
          } else if (formData.supplyMethodStr == '直供') {
            formData.supplyMethod = 0
          }
          formData.orgName = formData.departName
          formData.custName = this.objs.custName
          formData.custCode = this.objs.custCode
          formData.extendVos = that.forms
          formData.remarks = that.remarks
          formData.smokeLicenceStartDate = formData.smokeLicenceDate[0]
          formData.smokeLicenceEndDate = formData.smokeLicenceDate[1]
          formData.terminalCode = that.model.terminalCode
          let disPlayImgList = []
          this.disPlayImgList.forEach(item => {
            disPlayImgList.push({
              displayImg: item.url
            })
          })
          formData.disPlayImgList = disPlayImgList
          httpAction(this.addOrUpdateUrl, formData, method).then((res) => {
            if (res.success) {
              that.$message.success(res.message)
              that.$emit('ok')
              that.close()
            } else {
              that.$message.warning(res.message)
            }
          }).finally(() => {
            that.confirmLoading = false
            this.isDisable = false
          })
        } else {
          this.isDisable = false
        }
      })
    },
    handleCancel1() {
      this.visible1 = !this.visible1
    },
    handleCancel() {
      this.close()
    },
    initAreaData() {
      if (!this.areaData) {
        this.areaData = new Area()
      }
    },
    //选择是否为主号
    sexChangeEvent(e,i){
      this.forms.forEach((item, index) => {
        if(i==index){
          item.isMainStr='是'
        }else{
          item.isMainStr='否'
        }
      })
    },
    clickToadd(val, index) {
      this.dataSurces.length == 0
      if (val.target.innerText == '+') {
        this.forms.push({
          isMainStr: '否',
          contacts: '',
          telephone: ''
        })
      } else {
        this.forms.splice(index, 1)
      }
      // this.forms[0].isMainStr="是"
      console.log(this.forms)
      const { count, manobjList, dataSurces, forms } = this
      let dc = {}
      if (dataSurces.length == 0) {
        dataSurces.push({
          ...forms
        })
      } else {
        dataSurces.forEach((item, index) => {
          dc = Object.assign(item, forms)
          item = dc
        })
      }
      this.dataSurces2 = Array.from(new Set(this.dataSurces2.concat(dataSurces)))
      console.log(dataSurces2)
      this.dataSurces = []
      // this.forms = [{
      //   isMainStr: '请选择',
      //   contacts: '',
      //   telephone:'',
      // }]
    },
    onDelete(key) {
      const dataSurces = [...this.dataSurces]
      this.dataSurces = dataSurces.filter(item => item !== key)
    },
    onDeleteee(key) {
      const dataSurces2 = [...this.dataSurces2]
      this.dataSurces2 = dataSurces2.filter(item => item !== key)
    },
    // 收货地址删除
    onDeletes(key) {
      const dataSurces = [...this.ProductAdress]
      this.ProductAdress = dataSurces.filter(item => item !== key)
    },

    // getlist() {
    //   postAction(this.list).then(res => {
    //     let cust = res.result.records
    //     cust.forEach(item => {
    //
    //     })
    //   })
    // },
    // handleTableChange(pagination, filters, sorter) {
    //   //分页、排序、筛选变化时触发
    //   //TODO 筛选
    //   if (Object.keys(sorter).length > 0) {
    //     this.isorter.column = sorter.field
    //     this.isorter.order = 'ascend' == sorter.order ? 'asc' : 'desc'
    //   }
    //   this.ipagination = pagination
    //   this.getWarehouse()
    // },

    // getWarehouse() {
    //   postAction(this.warehouse, { current: this.ipagination6.current, size: this.ipagination6.size }).then(res => {
    //     this.dataSurces3 = res.result.records
    //     this.ipagination6.total = res.result.total || 0
    //   })
    // },
    handleSelectCode() {
      this.$refs.CodeConfigModal.showModal(this.userTypeTp)
    },
    // handelSaveOk(ob) {
    //   let that = this
    //   if (ob) {
    //     this.forms = {
    //       isMainStr: ob.name,
    //       custCode: ob.code
    //     }
    //
    //     // that.forms. = ob.code
    //     // that.forms.isMainStr = ob.name
    //     // that.forms.custCode = ob.code
    //
    //     // that.$nextTick(() => {
    //     //   that.form.setFieldsValue(pick(that.model, Object.keys(that.model)))
    //     // })
    //   }
    //   // 查询code
    // },

    custpersonOk(ob) {
      if (ob !== null && ob !== {}) {
        // this.forms.contacts = ob.contacts
        // this.forms.ogName = ob.ogName
        // this.forms.ogCode = ob.ogCode
        // this.forms.userName = ob.userName
        // this.forms.posCode = ob.posCode
        // this.forms.posName = ob.posName
        this.$set(this.forms, 'contacts', ob.contacts)
        this.$set(this.forms, 'ogName', ob.ogName)
        this.$set(this.forms, 'telephone', ob.telephone)
        this.$set(this.forms, 'ogCode', ob.ogCode)
        this.$set(this.forms, 'userName', ob.userName)
        this.$set(this.forms, 'posCode', ob.posCode)
        this.$set(this.forms, 'posName', ob.posName)
        return
      }
      this.$message.error('获取客户数据失败')
    },
    // 点击业务员响应{事件

    // handletoSelectPerson() {
    //   this.$refs.newCustperson.showModal(this.forms.custCode)
    // },
    // // 添加商品的数据回返
    productscontact(value) {
      console.log(value)
      this.dataSurces = value
      // let length = this.dataSurces.length
      // let a = []
      // value.forEach(item => {
      //   a.push(item)
      // })
      // this.dataSurces.splice(0, length, ...a)
    }
  }
}
</script>

<style scoped>
.gonghuoxinxi {
  width: 100%;
  border-bottom: 1px dashed black;
  margin: 10px 0;
  padding: 15px 5px;
  display: flex;
  flex-direction: column;
}
</style>
